
public class Person implements Comparable<Person> {
	
	private String firstName;
	private String lastName;
	
	public Person(String firstName, String lastName) {
		if (firstName == null || lastName == null) {
			throw new NullPointerException();
		}
		this.firstName = firstName;
		this.lastName = lastName;
	}
	
	@Override
	public String toString() {
		return String.format("%s, %s", firstName, lastName);
	}
	
	@Override
	public int compareTo(Person p) {
		int lastCmp = firstName.compareTo(p.firstName);
		return (lastCmp != 0 ? lastCmp : lastName.compareTo(p.lastName));
	}
}
